﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Text.RegularExpressions;
using com.lover.astd.common.manager;
using com.lover.astd.common.model.enumer;
using System.Collections;
using com.lover.astd.common.model.battle;
using com.lover.astd.common.model.building;
using com.lover.astd.common.model.attack;

namespace com.lover.astd.common.model
{
    public class User
    {
        private List<string> _ui_render_queue = new List<string>();
        public void addUiToQueue(string ui_key) { if (!_ui_render_queue.Contains(ui_key)) _ui_render_queue.Add(ui_key); }
        public string popUiFromQueue() { if (_ui_render_queue.Count > 0) { string ui_key = _ui_render_queue[0]; _ui_render_queue.RemoveAt(0); return ui_key; } else return ""; }
        
        #region 游戏内容相关
        private bool _gotLoginReward = true;
        /// <summary>
        /// 是否已经领过登录奖励
        /// </summary>
        public bool GotLoginReward
        {
            get { return _gotLoginReward; }
            set { _gotLoginReward = value; }
        }

        private int _id;
        /// <summary>
        /// 用户ID
        /// </summary>
        public int Id
        {
            get { return _id; }
            set { _id = value; }
        }
        private string _username;
        /// <summary>
        /// 用户名
        /// </summary>
        public string Username
        {
            get { return _username; }
            set { _username = value; }
        }
        private int _year;
        /// <summary>
        /// 年
        /// </summary>
        public int Year
        {
            get { return _year; }
            set { _year = value; }
        }
        private int _season;
        /// <summary>
        /// 季节, 1=春, 4=冬
        /// </summary>
        public int Season
        {
            get { return _season; }
            set { _season = value; }
        }
        private string[] _seasonNames = new string[] { "春", "夏", "秋", "冬" };
        /// <summary>
        /// 季节描述
        /// </summary>
        public string SeasonName
        {
            get { if (_season < 1) return ""; return _seasonNames[_season - 1]; }
        }
        private int _nationInt;
        /// <summary>
        /// nation的整型值
        /// </summary>
        public int NationInt
        {
            get { return _nationInt; }
            set { _nationInt = value; }
        }
        private string[] _nations = new string[] { "魏国", "蜀国", "吴国" };
        private string _nation;
        /// <summary>
        /// 国家
        /// </summary>
        public string Nation
        {
            get { return _nation; }
            set { _nation = value; }
        }
        private string _group;
        /// <summary>
        /// 玩家所在军团
        /// </summary>
        public string Group
        {
            get { return _group; }
            set { _group = value; }
        }
        private float _grainPrice;
        /// <summary>
        /// 粮食价格
        /// </summary>
        public float GrainPrice
        {
            get { return _grainPrice; }
            set { _grainPrice = value; }
        }
        private int _price;
        /// <summary>
        /// 物价
        /// </summary>
        public int Price
        {
            get { return _price; }
            set { _price = value; }
        }
        private int _magic;
        /// <summary>
        /// 强化魔力
        /// </summary>
        public int Magic
        {
            get { return _magic; }
            set { _magic = value; }
        }
        private bool _canUseGoldQh;
        /// <summary>
        /// 是否可以使用金币保证强化成功
        /// </summary>
        public bool CanUseGoldQh
        {
            get { return _canUseGoldQh; }
            set { _canUseGoldQh = value; }
        }
        private int _level;
        /// <summary>
        /// 用户级别
        /// </summary>
        public int Level
        {
            get { return _level; }
            set { _level = value; }
        }
        private int _gold;
        /// <summary>
        /// 金币
        /// </summary>
        public int Gold
        {
            get { return _gold; }
            set { _gold = value; }
        }
        private int _silver;
        /// <summary>
        /// 银币
        /// </summary>
        public int Silver
        {
            get { return _silver; }
            set { _silver = value; }
        }
        private int _maxSilver;
        /// <summary>
        /// 银币上限
        /// </summary>
        public int MaxSilver
        {
            get { return _maxSilver; }
            set { _maxSilver = value; }
        }
        private int _food;
        /// <summary>
        /// 粮食
        /// </summary>
        public int Food
        {
            get { return _food; }
            set { _food = value; }
        }
        private int _maxFood;
        /// <summary>
        /// 粮食上限
        /// </summary>
        public int MaxFood
        {
            get { return _maxFood; }
            set { _maxFood = value; }
        }
        private int _forces;
        /// <summary>
        /// 兵力
        /// </summary>
        public int Forces
        {
            get { return _forces; }
            set { _forces = value; }
        }
        private int _maxForces;
        /// <summary>
        /// 兵力上限
        /// </summary>
        public int MaxForces
        {
            get { return _maxForces; }
            set { _maxForces = value; }
        }
        private int _credit;
        /// <summary>
        /// 军功
        /// </summary>
        public int Credit
        {
            get { return _credit; }
            set { _credit = value; }
        }
        private int _prestige;
        /// <summary>
        /// 威望
        /// </summary>
        public int Prestige
        {
            get { return _prestige; }
            set { _prestige = value; }
        }
        private int _token;
        /// <summary>
        /// 军令
        /// </summary>
        public int Token
        {
            get { return _token; }
            set { _token = value; }
        }
        private long _tokenCdTime;
        /// <summary>
        /// 军令冷却时间
        /// </summary>
        public long TokenCdTime
        {
            get { return _tokenCdTime; }
            set { _tokenCdTime = value; }
        }
        private bool _tokenCdFlag;
        /// <summary>
        /// 军令是否已冷却
        /// </summary>
        public bool TokenCdFlag
        {
            get { return _tokenCdFlag && _tokenCdTime > 0; }
            set { _tokenCdFlag = value; }
        }
        private int _attackOrders;
        /// <summary>
        /// 攻击令
        /// </summary>
        public int AttackOrders
        {
            get { return _attackOrders; }
            set { _attackOrders = value; }
        }
        private int _stone;
        /// <summary>
        /// 玉石
        /// </summary>
        public int Stone
        {
            get { return _stone; }
            set { _stone = value; }
        }
        private int _gems;
        /// <summary>
        /// 宝石
        /// </summary>
        public int Gems
        {
            get { return _gems; }
            set { _gems = value; }
        }
        private List<ActivityType> _activities = new List<ActivityType>();
        public bool isActivityRunning(ActivityType tp)
        {
            foreach (ActivityType tmp in _activities)
            {
                if (tp == tmp) return true;
            }
            return false;
        }
        /// <summary>
        /// 每次获取playerinfo的时候清除所有的活动信息
        /// </summary>
        public void clearActivities() 
        {
            _activities.Clear();
        }
        public void removeActivity(ActivityType tp)
        {
            _activities.Remove(tp);
        }
        public void addActivity(ActivityType tp)
        {
            bool found = false;
            foreach (ActivityType tmp in _activities)
            {
                if (tp == tmp) { found = true; break; }
            }
            if (!found) _activities.Add(tp);
        }
        private int _curMovable = 0;
        /// <summary>
        /// 当前行动力
        /// </summary>
        public int CurMovable
        {
            get { return _curMovable; }
            set { _curMovable = value; }
        }
        #endregion

        #region temp store of execute data
        public int _stock_cd = 0;
        public bool _can_get_nation_task_reward = false;
        public bool _is_new_trade = false;
        #region impose
        /// <summary>
        /// 剩下的征收次数
        /// </summary>
        public int _impose_count = 0;
        /// <summary>
        /// 时间: 毫秒
        /// </summary>
        public long _impose_cdtime = 0;
        public bool _impose_hasCd = false;
        public int _impose_now_loyalty = 0;
        public int _impose_force_gold = 0;

        public bool _impose_isImposeEvent = false;
        public int _impose_imposeEvent_numNow = 0;
        public int _impose_imposeEvent_numMax = 80;
        public string _impose_imposeEvent_rewardStatus = "";

        public bool _impose_isRepayEvent = false;
        public int _impose_repayEvent_numNow = 0;
        public int _impose_repayEvent_numMax = 80;
        public string _impose_repayEvent_rewardStatus = "";
        #endregion

        #region fete
        public int[] _fete_min_levels = new int[] { 30, 50, 50, 101, 130, 50 };
        public string[] _fete_names = new string[] { "神农", "盘古", "共工", "伏羲", "女娲", "大祭祀" };
        public int[] _fete_gold = new int[] { 0, 0, 0, 0, 0, 0 };
        public int[] _fete_now_gold = new int[] { 0, 0, 0, 0, 0, 0 };
        public int[] _fete_now_free_times = new int[] { 0, 0, 0, 0, 0, 0 };
        #endregion

        #region dinner
        public int _dinner_count = 0;
        public int _dinner_in_time = 0;
        public bool _dinner_joined = false;
        public string _dinner_team_id = "";
        public string _dinner_team_creator = "";
        #endregion dinner

        #region building
        /// <summary>
        /// 所有建筑
        /// </summary>
        public List<Building> _buildings = new List<Building>();
        /// <summary>
        /// 所有建筑队列
        /// </summary>
        public Dictionary<int, BuildingLine> _buildingLines = new Dictionary<int, BuildingLine>();
        #endregion

        #region tufei
        private long _tuFeiCd = 0;
        /// <summary>
        /// 突飞cd时间, 单位:毫秒
        /// </summary>
        public long TuFeiCd
        {
            get { return _tuFeiCd; }
            set { _tuFeiCd = value; }
        }
        private bool _tuFeiCdFlag = false;
        /// <summary>
        /// 是否已经突飞cd了
        /// </summary>
        public bool TuFeiCdFlag
        {
            get { return _tuFeiCdFlag; }
            set { _tuFeiCdFlag = value; }
        }
        private int _tufeiNumber = 0;
        /// <summary>
        /// 突飞令个数
        /// </summary>
        public int TufeiNumber
        {
            get { return _tufeiNumber; }
            set { _tufeiNumber = value; }
        }
        private int _tufeiCredit = 0;
        /// <summary>
        /// 当前突飞一次所需要的军功
        /// </summary>
        public int TufeiCredit
        {
            get { return _tufeiCredit; }
            set { _tufeiCredit = value; }
        }
        private List<Hero> _heroes = new List<Hero>();
        /// <summary>
        /// 所有武将
        /// </summary>
        public List<Hero> Heroes
        {
            get { return _heroes; }
            set { _heroes = value; }
        }
        #endregion

        #region battle army
        public bool _battle_got_weapon_event_free_token = false;
        public int _battle_free_force_token = 0;
        public string _battle_current_army_id = "";
        public int _battle_max_army_id = 0;
        /// <summary>
        /// 征战事件NPC ID
        /// </summary>
        public int _battle_extra_npc_id = 0;
        /// <summary>
        /// 征战事件NPC剩余次数
        /// </summary>
        public int _battle_extra_npc_remains = 0;
        /// <summary>
        /// 征战事件NPC阵型
        /// </summary>
        public string _battle_extra_npc_formation = "不变阵";
        /// <summary>
        /// 所有军团Npc
        /// </summary>
        public List<Npc> _all_armys = new List<Npc>();
        /// <summary>
        /// 所有军团Npc
        /// </summary>
        /// <summary>
        /// 所有有装备的Npc或者可抓获的Npc
        /// </summary>
        public List<Npc> _all_npcs = new List<Npc>();
        #endregion

        #region attack player
        /// <summary>
        /// 城防值
        /// </summary>
        public int _attack_cityHp;
        /// <summary>
        /// 最大城防值
        /// </summary>
        public int _attack_maxCityHp;
        /// <summary>
        /// 城防值恢复cd
        /// </summary>
        public int _attack_cityHpRecoverCd;
        /// <summary>
        /// 战绩值
        /// </summary>
        public int _attack_battleScore = 0;
        public int[] _attack_battleScore_awardGot = new int[] { 0, 0, 0, 0, 0 };
        /// <summary>
        /// 当前鼓舞状态
        /// </summary>
        public int _attack_inspiredState = 0;
        /// <summary>
        /// 当前鼓舞等级
        /// </summary>
        public float _attack_inspiredEffect = 0;
        /// <summary>
        /// 是否在新地区
        /// </summary>
        public bool _inNewArea;
        /// <summary>
        /// 迁移cd
        /// </summary>
        public int _attack_transfer_cd = 0;
        /// <summary>
        /// 自己所在城市ID
        /// </summary>
        public int _attack_selfCityId = 0;
        public int _attack_remain_cityevent_num = 0;
        public string _attack_current_cityevent_name = "";
        public int _attack_current_cityevent_cdtime = 0;
        public int _attack_can_reward_cityevent = 0;
        
        public bool _attack_have_jail = false;

        public string _attack_nation_battle_city = "";
        public long _attack_nationBattleCd = 0;
        public int _attack_gongjian_status = 0;
        public long _attack_nationBattleRemainTime = 0;

        public List<AreaInfo> _attack_all_areas = new List<AreaInfo>();
        public AreaInfo getAreaById(int areaId)
        {
            foreach (AreaInfo area in _attack_all_areas)
            {
                if (area.areaid == areaId) return area;
            }
            return null;
        }
        public AreaInfo getAreaByName(string areaName)
        {
            foreach (AreaInfo area in _attack_all_areas)
            {
                if (area.areaname == areaName) return area;
            }
            return null;
        }
        public List<UserToken> _attack_user_tokens = new List<UserToken>();
        private Dictionary<int, int> _newAreaCityInfo = new Dictionary<int, int>();
        public Dictionary<int, int> getNewAreaCityInfo() { return _newAreaCityInfo; }
        public void setNewAreaCityNation(int cityid, int nation) { if (cityid >= 101 && cityid <= 136) _newAreaCityInfo[cityid] = nation; }
        #endregion

        #region equipment
        /// <summary>
        /// 背包已使用空间
        /// </summary>
        public int _storeUsedSize = 0;
        /// <summary>
        /// 背包总空间
        /// </summary>
        public int _storeTotalSize = 0;
        /// <summary>
        /// 获取用户可强化的装备
        /// </summary>
        public List<Equipment> _qhEquips = new List<Equipment>();
        /// <summary>
        /// 获取用户可魔化的装备
        /// </summary>
        public List<Equipment> _mhEquips = new List<Equipment>();
        /// <summary>
        /// 获取用户仓库中的装备
        /// </summary>
        public List<Equipment> _storeEquips = new List<Equipment>();
        /// <summary>
        /// 兵器概况
        /// </summary>
        public string _weapon_info = "";
        #endregion

        #endregion

        public void refreshPlayerInfo(XmlNode updates)
        {
            if (updates == null || !updates.HasChildNodes) return;
            XmlNodeList childs = updates.ChildNodes;
            int sys_gold = -1, user_gold = -1;
            foreach (XmlNode child in childs)
            {
                if (child.Name == "perdayreward") _gotLoginReward = false; // 表示每日金币还未领取, 只要有这个字段就表示没领
                else if (child.Name == "playerid") _id = Int32.Parse(child.InnerText);
                else if (child.Name == "playername") _username = child.InnerText;
                else if (child.Name == "playerlevel") _level = Int32.Parse(child.InnerText);
                else if (child.Name == "copper") _silver = Int32.Parse(child.InnerText);
                else if (child.Name == "food") _food = Int32.Parse(child.InnerText);
                else if (child.Name == "forces") _forces = Int32.Parse(child.InnerText);
                else if (child.Name == "sys_gold") sys_gold = Int32.Parse(child.InnerText);
                else if (child.Name == "user_gold") user_gold = Int32.Parse(child.InnerText);
                else if (child.Name == "jyungong") _credit = Int32.Parse(child.InnerText);
                else if (child.Name == "prestige") _prestige = Int32.Parse(child.InnerText);
                else if (child.Name == "year") _year = Int32.Parse(child.InnerText);
                else if (child.Name == "season") _season = Int32.Parse(child.InnerText);
                else if (child.Name == "token") _token = Int32.Parse(child.InnerText);
                else if (child.Name == "tokencd") _tokenCdTime = Int64.Parse(child.InnerText);
                else if (child.Name == "tokencdflag") _tokenCdFlag = child.InnerText == "1";
                else if (child.Name == "innewarea") _inNewArea = child.InnerText == "1";
                else if (child.Name == "nation")
                {
                    _nationInt = Int32.Parse(child.InnerText);
                    if (_nationInt <= 0) _nation = "中立";
                    else _nation = _nations[_nationInt - 1];
                }
                else if (child.Name == "atttoken" || child.Name == "attacktoken") _attackOrders = Int32.Parse(child.InnerText);
                else if (child.Name == "cityhp") _attack_cityHp = Int32.Parse(child.InnerText);
                else if (child.Name == "maxcityhp") _attack_maxCityHp = Int32.Parse(child.InnerText);
                else if (child.Name == "cityhprecovercd") _attack_cityHpRecoverCd = Int32.Parse(child.InnerText);
                else if (child.Name == "inspirestate") _attack_inspiredState = Int32.Parse(child.InnerText);
                else if (child.Name == "inspireeffect") _attack_inspiredEffect = float.Parse(child.InnerText);
                else if (child.Name == "battlescore") _attack_battleScore = Int32.Parse(child.InnerText);
                else if (child.Name == "curactive") _curMovable = Int32.Parse(child.InnerText);
                else if (child.Name == "bowlder") _stone = (int)(Int32.Parse(child.InnerText) / 1000);
            }
            if (sys_gold >= 0 && user_gold >= 0) _gold = sys_gold + user_gold;
            else if (sys_gold >= 0) _gold = sys_gold;
            else if (user_gold >= 0) _gold = user_gold;
            // 判断活动//////////////////////////////////////////////////////////////////////////
            //世界军团
            XmlNode nian_node = updates.SelectSingleNode("nian");
            if (nian_node != null) addActivity(ActivityType.WorldArmy);
            //银币翻牌
            XmlNode cooperevent_node = updates.SelectSingleNode("gifteventcopper");
            if (cooperevent_node != null) addActivity(ActivityType.SilverFlop);
            //宝石翻牌
            XmlNode gemevent_node = updates.SelectSingleNode("gifteventbaoshi4");
            if (gemevent_node != null) addActivity(ActivityType.GemFlop);
            //////////////////////////////////////////////////////////////////////////
            XmlNode dumpevent_node = updates.SelectSingleNode("dumpevent");
            int dumpevent = 0;
            if (dumpevent_node != null) Int32.TryParse(dumpevent_node.InnerText, out dumpevent);
            if (dumpevent == 2) addActivity(ActivityType.WeaponEvent);//兵器活动
            else if (dumpevent == 1) addActivity(ActivityType.JailEvent); // 典狱活动
            //征收活动
            XmlNode eventtime_node = updates.SelectSingleNode("eventtime");
            if (eventtime_node != null && eventtime_node.InnerText.Equals("1")) addActivity(ActivityType.ImposeEvent);
            //武将训练活动
            XmlNode general_eventtime_node = updates.SelectSingleNode("isgeneraleventtime");
            if (general_eventtime_node != null && general_eventtime_node.InnerText.Equals("1")) addActivity(ActivityType.HeroTrainEvent);
            //考古活动
            
            //////////////////////////////////////////////////////////////////////////
            //武斗会
            XmlNode kfwd_node = updates.SelectSingleNode("showkfwd");
                //0=没有活动, 1=还未开始, 2=开打中, 3=已结束
            if (kfwd_node != null && !(kfwd_node.InnerText.Equals("0"))) addActivity(ActivityType.PlayerCompete);
            ///武斗会庆祝活动
            XmlNode kfwd_event_node = updates.SelectSingleNode("kfwdeventreward");
            //0=没有活动, 1=还未开始, 2=开打中, 3=已结束
            if (kfwd_event_node != null && !(kfwd_event_node.InnerText.Equals("0"))) addActivity(ActivityType.PlayerCompeteEvent);

            //跨服争霸赛
            XmlNode kfzb_node = updates.SelectSingleNode("showkfzb");
            if (kfzb_node != null && !(kfzb_node.InnerText.Equals("0"))) addActivity(ActivityType.CrossplatformCompete);
            //盛宴活动
            XmlNode banquet_node = updates.SelectSingleNode("banquet");
            if (banquet_node != null) addActivity(ActivityType.KfBanquet);
            //////////////////////////////////////////////////////////////////////////
            //犒赏活动
            XmlNodeList boxmodel_nodes = updates.SelectNodes("boxmodels/boxmodel/list/value/mode");
            foreach (XmlNode node in boxmodel_nodes)
            {
                if (node.InnerText == "1") addActivity(ActivityType.GiftEvent);
            }
            //XmlNode giftevent_node = updates.SelectSingleNode("giftevent");
            //if (giftevent_node != null) addActivity(ActivityType.GiftEvent);
            //祭祀活动
            XmlNode fete_event_node = updates.SelectSingleNode("feteevent");
            if (fete_event_node != null) addActivity(ActivityType.FeteEvent);

            // notice中寻找
            XmlNodeList notice_nodes = updates.SelectNodes("notice/property/content");
            foreach (XmlNode notice_node in notice_nodes)
            {
                if (notice_node == null) continue;
                string content = notice_node.InnerText;
                string[] contents = content.Split(' ');
                string tmp = "";
                foreach (string con in contents)
                {
                    if (con == null || con.Trim().Length == 0) continue;
                    tmp += con.Trim();
                    if (!tmp.StartsWith("【") || !(tmp.EndsWith(":00") || tmp.EndsWith(":30") || tmp.EndsWith("点"))) continue;
                    List<ActivityType> acttypes = generateEventFromNotice(tmp);
                    foreach(ActivityType tp in acttypes) addActivity(tp);
                    tmp = "";
                }
            }
        }
        private List<ActivityType> generateEventFromNotice(string notice_content)
        {
            DateTime now = TimeMgr.DateTimeNow;
            List<ActivityType> acttypes = new List<ActivityType>();
            // 首先判断时间, 时间在当前时间内再考虑是什么活动
            Regex re = new Regex(@"【(.*)】([^-—]*)[-—至到 ]+([^-—]*)", RegexOptions.None);
            MatchCollection matches = re.Matches(notice_content);
            if (matches != null && matches.Count > 0 && matches[0] != null)
            {
                if (matches[0].Groups != null && matches[0].Groups.Count >= 4)
                {
                    string name = matches[0].Groups[1].Value;
                    string start_time = matches[0].Groups[2].Value;
                    string end_time = matches[0].Groups[3].Value;
                    long start_mseconds = parseDateTimeMSeconds(start_time);
                    long end_mseconds = parseDateTimeMSeconds(end_time);
                    if (start_mseconds > end_mseconds) // 肯定是end没写日期, end_mseconds直接加上1天
                    {
                        end_mseconds += 24 * 60 * 60 * 1000;
                        if (start_mseconds > end_mseconds)
                        {
                            // 加了一天还是start>end, 肯定跨年了
                            // 如果当前时间在12月, 那么end在下一年
                            if (now.Month == 12) end_mseconds += (long)365 * 24 * 60 * 60 * 1000;
                            // 如果当前时间在1月, 那么start在上一年
                            else if (now.Month == 1) start_mseconds -= (long)365 * 24 * 60 * 60 * 1000;
                        }
                    }
                    if (start_mseconds < TimeMgr.TimeStamp && end_mseconds > TimeMgr.TimeStamp)
                    {
                        if (name.IndexOf("典狱活动") >= 0) acttypes.Add(ActivityType.JailEvent);
                        if (name.IndexOf("宝石翻牌") >= 0) acttypes.Add(ActivityType.GemFlop);
                        if (name.IndexOf("银币翻牌") >= 0) acttypes.Add(ActivityType.SilverFlop);
                        if (name.IndexOf("军资回馈") >= 0) acttypes.Add(ActivityType.RepayEvent);
                        if (name.IndexOf("考古活动") >= 0) acttypes.Add(ActivityType.ArchEvent);
                        if (name.IndexOf("盛宴活动") >= 0) acttypes.Add(ActivityType.KfBanquet);
                        if (name.IndexOf("犒赏活动") >= 0) acttypes.Add(ActivityType.GiftEvent);
                        if (name.IndexOf("世界军团") >= 0) acttypes.Add(ActivityType.KfBanquet);
                        if (name.IndexOf("古城探宝") >= 0) acttypes.Add(ActivityType.TreasureGame);
                        if (name.IndexOf("元旦") >= 0) acttypes.Add(ActivityType.NewYearEvent);
                    }
                }
            }
            return acttypes;
        }
        private long parseDateTimeMSeconds(string dtstr)
        {
            dtstr = dtstr.Replace("凌晨", "");
            dtstr = dtstr.Replace("点", ":00");
            dtstr = dtstr.Replace("24:00", "23:59");
            DateTime dt;
            DateTime.TryParse(dtstr, out dt);
            return Decimal.ToInt64(Decimal.Divide(dt.Ticks - 621355968000000000, 10000));
        }
        public void updateLimits(XmlNode updates)
        {
            if (updates == null || !updates.HasChildNodes) return;
            XmlNodeList childs = updates.ChildNodes;
            foreach (XmlNode cnode in childs)
            {
                if (cnode.Name == "maxfood") _maxFood = Int32.Parse(cnode.InnerText);
                else if (cnode.Name == "maxcoin") _maxSilver = Int32.Parse(cnode.InnerText);
                else if (cnode.Name == "maxforce") _maxForces = Int32.Parse(cnode.InnerText);
            }
        }
        public User() { }
    }
}
